package com.shop.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shop.admin.dao.ShopSlideshowDao;
import com.shop.admin.entity.ShopSlideshow;
import com.shop.admin.service.ShopSlideshowService;
import com.shop.admin.utils.PageUtils;
import com.shop.admin.utils.Query;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ShopSlideshowServiceImpl extends ServiceImpl<ShopSlideshowDao, ShopSlideshow> implements ShopSlideshowService {

    @Override
    //@Cacheable(value = {"slideshow"},key = "'getSlideshow'",sync = true)
    public PageUtils queryPage(Map<String, Object> params) {

        IPage<ShopSlideshow> page = this.page(
                new Query<ShopSlideshow>().getPage(params),
                new QueryWrapper<ShopSlideshow>().lambda().eq(ShopSlideshow::getOrgId,params.get("orgId"))
        );
        return new PageUtils(page);
    }

    @Override
    //@CacheEvict(value = "slideshow",allEntries = true)
    public void updateSlideshow(ShopSlideshow slideshow) {
        this.saveOrUpdate(slideshow);
    }

    @Override
    //@CacheEvict(value = "slideshow",allEntries = true)
    public void removeMenuByIds(List<Long> asList) {
            this.baseMapper.deleteBatchIds(asList);
    }
}
